﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using Meqs.Utilities;
using Meqs.Entity;
using Meqs.Logic.Interface;
using System.Collections.Generic;

public partial class Credit_Teacher_RuleSettings_ReviewTeacherEval : System.Web.UI.Page
{
    protected int currHistoryId = 0;
    protected string title;
    protected IList<TeacherEvalType> typeList = null;
    protected IList<TeacherEvalItem> itemList = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string s = Request.Params["historyId"];
            int.TryParse(s, out currHistoryId);
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", Common.GetConstSchoolMark());
            ht.Add("RID", currHistoryId);
            IList<TeacherEvalHistory> th = Container<ITeacherEvalHistoryLogic>.Instance.FindAll(ht);
            title = "";
            if (th.Count > 0)
            {
                title = th[0].Caption;
            }
            btnBind_Click(null, null);
        }
    }
    [WebMethod]
    public static string GetExcel(ExcelTableCell[][] cells, string title, string stitle)
    {
        string temp_path = HttpContext.Current.Server.MapPath("../../../");
        string save_path = temp_path + "\\download\\" + DateTime.Now.Ticks.ToString() + "样表模板.xls";
        HttpContext.Current.Session["filepath"] = save_path;
        Meqs.Utilities.ExcelUtil.ExcelExport(save_path, "样表模板", title, stitle, 1, 1, cells);
        return "";
    }
    protected void btnBind_Click(object sender, EventArgs e)
    {
        Hashtable table = new Hashtable();
        table.Add("SchoolMark", Common.GetConstSchoolMark());
        table.Add("HistoryID", currHistoryId);

        ITeacherEvalTypeLogic logic = Container<ITeacherEvalTypeLogic>.Instance;
        ITeacherEvalItemLogic itemlogic = Container<ITeacherEvalItemLogic>.Instance;
        typeList = logic.FindAll(table);
        itemList = itemlogic.FindAll(table);
        Repeater1.DataSource = typeList;
        Repeater1.DataBind();
    }
    protected string GetContent(int typeID, string caption)
    {
        string str = "<tr ><td rowspan={rowNum} style='text-align: left; padding-left: 5px;'>" + caption + "</td>";

        int count = 0;
        foreach (TeacherEvalItem t in itemList)
        {
            if (t.TypeID == typeID)
            {
                if (count != 0)
                {
                    str += "<tr>";
                }
                str += "<td style='text-align: left; padding-left: 5px;'>" + t.Caption + "</td><td></td></tr>";

                count++;
            }
        }
        if (count == 0)
            return "";
        str = str.Replace("{rowNum}", Convert.ToString(count));
        return str;
    }

}
